#ifndef _RSA_H
#define _RSA_H

class CRsa
{
private:
	// Open key
	unsigned long long m_open_key [2];
	// Close key
	unsigned long long m_close_key [2];
	
	char * m_decode;
	int * m_code;
	int m_size;
	
	static unsigned long long MersenneNumber (int n);
	static unsigned long long FindEasyNumber (unsigned long long start);
	static unsigned long long EasyNumberWith (unsigned long long start,unsigned long long with);
	static unsigned long long PowerMod(unsigned long long a, unsigned long long b, unsigned long long c);
	static unsigned long long FindE (unsigned long long start,unsigned long long d, unsigned long long yn);
	
	void GenerateKeys (unsigned long long p, unsigned long long q);
public:
	CRsa (int ps = 5, int qs = 7);
	CRsa (char * decode, int size, int ps = 5, int qs = 7);
	CRsa (int * code, int size, int ps = 5, int qs = 7);
	~CRsa ();
	
	void SetDecodeMsg (char * decode, int size);
	void SetCodeMsg (int * code, int size);
	char * GetDecodeMsg ();
	int * GetCodeMsg ();
	int GetSize ();
	void decoder ();
	void coder ();
};

int * codeRsaMsg (char *msg, int size);
char * decodeRsaMsg (int * msg, int size);

#endif